#include "main.h"
#include "widget.h"
#include "enter.h"

int main()
{
	int lcd = open("/dev/fb0", O_RDWR);
	int(*lcdp)[800] = (int(*)[800])mmap(NULL, 800 * 480 * 4, PROT_READ | PROT_WRITE, MAP_SHARED, lcd, 0);
	int i, j, c = 1;
	int enreturn = 1;
	int wireturn;
	while (wireturn != -2)
	{
		enreturn = 1;
		wireturn = widget(lcdp);
		if (wireturn == -1)
		{
			printf("warning:error in widget\n");
			usleep(1000);
		}
		else if (wireturn == 1)
		{
			while (enreturn != -1)
			{
				enreturn = enter(lcdp, &c);
				printf("enreturn:%d\n", enreturn);
				if (enreturn == 0)
				{
					printf("enter error\n");
					return -1;
				}
				else if (enreturn == 1)
					continue;
			}
		}
		else if (wireturn == 0)
			continue;
	}
	for (i = 0; i < 480; i++)
		for (j = 0; j < 800; j++)
			lcdp[i][j] = b;
	close(lcd);
	return 0;
}